<?php
class AdminAction extends ActionBase {

	public $modelName = '';
	public $dataProvider = array();
	public $searchColumns = array('id');
	public $dataColumns = array();
	public $operates = array();
	public $renderPartial = false;
	public $gridId = null;
	public $ajaxUpdate = true;
	public $pageSize = 10;
	
	public function run() {
		$this->prepare();
		
		$modelName = $this->modelName;
		$model = $this->controller->loadModel();
		$model->setScenario('search');
		$model->unsetAttributes();
		if(isset($_GET[$modelName])) {
			$model->attributes = $_GET[$modelName];
		}
		$operates = $this->operates;
		if($this->operates === array()) {
			$operates = array(
				CONSTANT::OP_CREATE => array(
					'href' => $this->controller->createUrl('edit'),
					'style' => OperatorButton::STYLE_BLUE,
				),
			);
		} 
		
		$this->controller->operates = $operates;
		$this->controller->layout = $this->layout;
		$foo = $this->renderPartial ? 'renderPartial' : 'render';
		
		
		$this->controller->{$foo}($this->view, array(
			'model' => $model,
			'gridId' => $this->gridId,
			'dataProvider' => $model->search(),
			'searchColumns' => $this->searchColumns,
			'dataColumns' => $this->dataColumns,
		));
		
	}
	
	
}